#include<bits/stdc++.h>
using namespace std;
int ta,n,m,l,vm;
struct edge{
    int d,v,a;
    float x;
    bool not_p;
};
edge c[100010];
int p[100010];
struct fan{
    int h,t;
};
vector<int>a[100010];
fan det[100010];
vector<int>pn[100010];

bool is(int i,int j)
{
    for(int k=0;k<pn[i].size();k++)
    {
        if(pn[i][k]!=pn[j][k])return false;
    }
    return true;
}


int f[100010];
int fpn[100010];
int search1(int maxn)
{
    //cout<<123<<endl;
    int minn=1e9,maxi;
    for(int i=0;i<m;i++)
    {
        if(maxn-(pn[i].size())<=minn)
        {
            minn=maxn-pn[i].size();
            maxi=i;
        }
    }
    //cout<<minn<<endl;
    int j=0;
    for(int i=0;i<m;i++)
    {
        //cout<<pn[i].size()<<"*"<<endl;
        if(maxn-(pn[i].size())==minn)
        {
            fpn[j++]=i;
            //cout<<i<<" ";
        }
    }
    //for(int j=0;j<maxn;j++)cout<<fpn[j]<<" ";
    //cout<<12313214;
    int cnt=maxn;
    memset(f,0,100010);
    //cout<<pn[1]<<" "<<pn[2]<<" "<<pn[4]<<endl;
    for(int i=0;i<maxn;i++)
    {
        for(int j=i;j<maxn;j++)
        {
            if(is(fpn[i],fpn[j])&&!f[i]&&f[j])
            {
                f[i]=1;
                //cout<<cnt<<" ";
                cnt--;
            }
        }
    }
    return cnt;
    //cout<<endl;

}


int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&ta);
    //cout<<2<<endl;
    for(int k=0;k<ta;k++)
    {
        //cout<<1231<<endl;
        scanf("%d%d%d%d",&n,&m,&l,&vm);
        //cout<<123132<<endl;
        for(int i=0;i<n;i++)
        {
            scanf("%d%d%d",&c[i].d,&c[i].v,&c[i].a);
            //cout<<123<<endl;
            int xm=abs((float)(c[i].v)*(c[i].v)/(2*c[i].a));
            int xmm=abs((float)((c[i].v)*(c[i].v)-vm*vm)/(2*c[i].a));
            c[i].x=min(xmm,xm);
            //c[i].x=abs((float)((c[i].v)*(c[i].v)-vm*vm)/(2*c[i].a));
        }
        for(int i=0;i<m;i++)
        {
            scanf("%d",&p[i]);
        }
        for(int i=0;i<n;i++)
        {
            if(c[i].a==0)
            {
                if(c[i].v<=vm)
                {
                    det[i].h=-1;
                    det[i].t=-1;
                }
                else
                {
                    det[i].h=c[i].d;
                    det[i].t=l;
                }
            }
            else
            {
                if(c[i].a>0)
                {
                    det[i].h=c[i].d+c[i].x;
                    det[i].t=l;
                    if(c[i].v>vm)
                    {
                        det[i].h=c[i].d;
                        det[i].t=l;
                    }
                }
                else
                if(c[i].a<0)
                {
                    if(c[i].v<=vm)
                    {
                        det[i].h=-1;
                        det[i].t=-1;
                    }
                    else if(c[i].v>vm)
                    {
                        det[i].h=c[i].d;
                        det[i].t=c[i].d+c[i].x;
                    }
                }
            }
            //cout<<"1*"<<endl;
           //cout<<det[i].h<<" "<<det[i].t<<endl;
        }//
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(c[i].a>0)
                {
                    if(det[i].h<p[j]&&p[j]<=det[i].t)
                    {
                        a[i].push_back(j);
                        pn[j].push_back(i);
                    }
                }
                else if(c[i].a<0)
                {
                    if(det[i].h<=p[j]&&p[j]<det[i].t)
                    {
                        a[i].push_back(j);
                        pn[j].push_back(i);
                    }
                }
                else if(c[i].a==0)
                {
                    if(det[i].h<=p[j]&&p[i]<=det[i].t)
                    {
                        a[i].push_back(j);
                        pn[j].push_back(i);
                    }
                }
            }
        }
        int cnt=0;
        for(int i=0;i<n;i++)
        {
            if(a[i].size()>0)cnt++;
            //cout<<a[i].size()<<endl;

        }
        int ans=search1(cnt);
        printf("%d %d\n",cnt,ans);

    }




    fclose(stdin);
    fclose(stdout);
    return 0;
}
